﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:ModbusHelper.WPF.Controls">

    <Style TargetType="{x:Type local:NumericInputBox}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:NumericInputBox}" >
                    <Border x:Name="PART_MAIN_BORDER" 
                            Background="{TemplateBinding Background}" 
                            BorderBrush="{TemplateBinding BorderBrush}" 
                            BorderThickness="2"
                            Padding="0,0,5,0">

                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="{Binding Path=CaptionWidth, RelativeSource={RelativeSource TemplatedParent}}"/>
                                <ColumnDefinition Width="{Binding Path=SeparatorWidth, RelativeSource={RelativeSource TemplatedParent}}" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <!-- Caption -->
                            <TextBlock Grid.Column="0" Text="{TemplateBinding Caption}" Margin="5,2" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="{TemplateBinding FontSize}" FontWeight="Bold" Foreground="#FF237BE4"/>
                            
                            <!-- Separator-->
                            <Path x:Name="PART_SEPARATOR" Grid.Column="1"  StrokeThickness="3" Margin="0,-2"  Stroke="{TemplateBinding BorderBrush}" Stretch="Fill" SnapsToDevicePixels="True" />
                            
                            <Grid Grid.Column="2">
                            
                                <TextBlock x:Name="PART_VIEW_VALUE" Visibility="Visible"
                                    Text="{Binding Mode=TwoWay, Path=Value, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="Center" HorizontalAlignment="Right" />
                            
                                <TextBox x:Name="PART_EDIT_VALUE" Background="Yellow" Visibility="Collapsed" VerticalAlignment="Center" HorizontalAlignment="Right"  BorderThickness="0"/>
                            </Grid>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>